import math

PRIMES = [112272535095293] * 100

def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    sqrt_n = int(math.floor(math.sqrt(n)))
    for i in range(3, sqrt_n + 1, 2):
        if n % i == 0:
            return False
    return True

def single_thread():
    for number in PRIMES:
        is_prime(number)
    
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
def mult_thread():
    with ThreadPoolExecutor() as pool:
        pool.map(is_prime, PRIMES)

def mult_process():
    with ProcessPoolExecutor() as pool:
        pool.map(is_prime, PRIMES)

import time
s = time.time()
single_thread()
e = time.time()
print('single thread cost ', e - s)
s = time.time()
mult_thread()
e = time.time()
print('multi thread cost ', e - s)
s = time.time()
mult_process()
e = time.time()
print('multi process cost ', e - s)

# single thread cost  14.621481895446777
# multi thread cost  16.00286340713501
# multi process cost  1.3232767581939697